/*
 * AdministradorApp.java
 */

package administrador;

import java.awt.Component;
import java.util.EventObject;
import javax.swing.JOptionPane;
import org.jdesktop.application.Application;
import org.jdesktop.application.SingleFrameApplication;

/**
 * The main class of the application.
 */
public class AdministradorApp extends SingleFrameApplication {
    int bodega=0;
    Conexion c;
    
    /**
     * At startup create and show the main frame of the application.
     */
    @Override protected void startup() {
      
        inicio i=new inicio(this/*aview*/);
        i.setVisible(true);
       

        
        addExitListener(new ExitListener() {
            public boolean canExit(EventObject e) {
                boolean bOkToExit = false;
                Component source = (Component) e.getSource();
                bOkToExit = JOptionPane.showConfirmDialog(source,
                                "Seguro desea Salir del Administrador? Se Realizara un Respaldo Automatico Espere unos segundos..") ==
                                JOptionPane.YES_OPTION;
                if(bOkToExit){
                    //Si Quiere Salir o apaga la computadora se hara un respaldo web
//                    PanelActualizacion pa=new PanelActualizacion();
//                    ProActualizaWebDB paw=new ProActualizaWebDB(c,pa,bodega);
//                    paw.run();
//
//                    PanelActualizacion pa2=new PanelActualizacion();
//                    ProcSubeFacturas paw2=new ProcSubeFacturas(c,pa2,bodega);
//                    paw2.run();
                    
                    
                }
                return bOkToExit;
            }
            public void willExit(EventObject event) {

            }
        });
        
  
    }
    
    /**
     * This method is to initialize the specified window by injecting resources.
     * Windows shown in our application come fully initialized from the GUI
     * builder, so this additional configuration is not needed.
     */
    @Override protected void configureWindow(java.awt.Window daniel1) {
    }

    /**
     * A convenient static getter for the application instance.
     * @return the instance of AdministradorApp
     */
    public static AdministradorApp getApplication() {
        return Application.getInstance(AdministradorApp.class);
    }

    /**
     * Main method launching the application.
     */
    public static void main(String[] args) {
        launch(AdministradorApp.class, args);
    }
}
